package cn.luischen.service.user.impl;

<<<<<<< HEAD
import org.springframework.beans.factory.annotation.Autowired;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import cn.luischen.service.user.UserService;
import cn.luischen.utils.TaleUtils;
import cn.luischen.dao.UserDao;
import cn.luischen.exception.BusinessException;
import cn.luischen.constant.ErrorConstant;
import cn.luischen.model.UserDomain;
import org.springframework.transaction.annotation.Transactional;

import org.powermock.reflect.Whitebox;
import org.mockito.Mock;
import static org.junit.Assert.fail;
import org.junit.runner.RunWith;
import java.util.HashMap;
import java.util.ArrayList;
import org.mockito.MockitoAnnotations;
import com.alibaba.fastjson.JSONArray;
import org.junit.After;
import org.powermock.core.classloader.annotations.PrepareForTest;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import java.lang.reflect.Method;
import org.junit.rules.ExpectedException;
import org.mockito.InjectMocks;
import org.junit.Test;
import static org.junit.Assert.*;
import com.unitspirit.runtime.*;
import org.mockito.Mockito;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import org.junit.Rule;
import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
import static org.junit.Assert.assertTrue;
import com.alibaba.fastjson.parser.ParserConfig;

/**
* The class <code>UserServiceImplTest</code> contains tests for the class <code>{@link UserServiceImpl}</code>.
* Copyright (c) 2020
* 
* @generatedBy UnitSpirit at 2021-09-07 17:52:06
* @version 1.0.20210903
*/

@PowerMockIgnore({ "javax.management.*" })
@RunWith(PowerMockRunner.class)
@PrepareForTest({ cn.luischen.utils.TaleUtils.class, cn.luischen.dao.UserDao.class })
public class UserServiceImpl_login_WGTest {

	@InjectMocks
	cn.luischen.service.user.impl.UserServiceImpl unitspirit_fixture;
	@Mock
	cn.luischen.dao.UserDao mock_UserDao;

=======
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import cn.luischen.constant.ErrorConstant;
import cn.luischen.dao.UserDao;
import cn.luischen.exception.BusinessException;
import cn.luischen.model.UserDomain;
import cn.luischen.service.user.UserService;
import cn.luischen.utils.TaleUtils;

import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
import org.junit.Rule;
import org.junit.runner.RunWith;
import org.junit.rules.ExpectedException;
import org.junit.Test;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.stubbing.Answer;
import java.lang.reflect.Method;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.parser.ParserConfig;
import java.util.Map;
import java.util.List;
import com.unitspirit.runtime.*;

/**
 * The class contains tests for the class cn.luischen.service.user.impl.UserServiceImpl.
 *
 * @generatedBy UnitSpirit CreateTemplateTestFile4
 * @version 1.0.9.11 
 */
@PowerMockIgnore({ "javax.management.*" })
@RunWith(PowerMockRunner.class)
@PrepareForTest({ cn.luischen.utils.TaleUtils.class,
		cn.luischen.exception.BusinessException.class,
		cn.luischen.dao.UserDao.class })
public class UserServiceImpl_login_WGTest {
>>>>>>> 3b028d6f1d2dd25e613c470e379df4ff28f4935e
	@Rule
	public ExpectedException unitspirit_thrown = ExpectedException.none();

	/**
<<<<<<< HEAD
	* 测试方法初始化.
	* 
	* @throws Exception 
	*         if the initialization fails for some reason 
	*  
	* @generatedBy UnitSpirit at 2021-09-07 17:52:06
	*/
=======
	 * 测试方法初始化.
	 * 
	 * @throws Exception 
	 *         if the initialization fails for some reason 
	 *  
	 * @generatedBy UnitSpirit at 2021-12-06 21:50:31
	 */
>>>>>>> 3b028d6f1d2dd25e613c470e379df4ff28f4935e
	@org.junit.Before
	public void setUp() throws Exception {
		try {
			GlobalUnitInit.init();
			MockitoAnnotations.initMocks(this);
			ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

<<<<<<< HEAD
	/**
	* @date 2021-09-07 17:52:06
	* @see cn.luischen.service.user.impl.UserServiceImpl#login
	* @category auto generate by UnitSpirit  
	* @author UnitSpirit   
	*/
	@Test
	public void test_login_0113_190013_202_2_01() throws Throwable {
		//被测函数参数定义
		String String_p_0 = "admin";
		String String_p_1 = "123456";
		//成员变量设置

		//返回值定义 
		String result_expected = "{\"activated\":0,\"created\":1490756162,\"email\":\"1034683568@qq.com\",\"groupName\":\"visitor\",\"logged\":0,\"password\":\"a66abb5684c45962d887564f08346e8d\",\"screenName\":\"admin1\",\"uid\":1,\"username\":\"admin\"}";

		PowerMockito.mockStatic(cn.luischen.utils.TaleUtils.class);
		java.lang.String mock_result_String2 = "\"a66abb5684c45962d887564f08346e8d\"";
		cn.luischen.model.UserDomain mock_result_UserDomain1 = JSON.parseObject(
				"{\"activated\":0,\"created\":1490756162,\"email\":\"1034683568@qq.com\",\"groupName\":\"visitor\",\"logged\":0,\"password\":\"a66abb5684c45962d887564f08346e8d\",\"screenName\":\"admin1\",\"uid\":1,\"username\":\"admin\"}",
				cn.luischen.model.UserDomain.class);

		PowerMockito.when(cn.luischen.utils.TaleUtils.MD5encode(anyString())).thenReturn(mock_result_String2);
		PowerMockito.when(mock_UserDao.getUserInfoByCond(anyString(), anyString())).thenReturn(mock_result_UserDomain1);

		cn.luischen.model.UserDomain unitspirit_result = unitspirit_fixture.login(String_p_0, String_p_1);
		UnitAssert.assertEquals(result_expected, UnitSpiritFastJsonUtil.getJsonString2(unitspirit_result));
	}

	/**
	* @date 2021-09-07 17:52:06
	* @see cn.luischen.service.user.impl.UserServiceImpl#login
	* @category auto generate by UnitSpirit  
	* @author UnitSpirit   
	*/
	@Test
	public void test_login_0113_190013_202_5_01() throws Throwable {
=======
	@InjectMocks
	cn.luischen.service.user.impl.UserServiceImpl unitspirit_fixture;

	@Mock
	cn.luischen.dao.UserDao mock_UserDao;

	/**
	 * @date 2021-12-06 21:50:31
	 * @see cn.luischen.service.user.impl.UserServiceImpl#login
	 * @category null  
	 * @author null  
	 */
	@Test(expected = cn.luischen.exception.BusinessException.class)
	public void test_login_20211109_110317_805_2_01() throws Throwable {
>>>>>>> 3b028d6f1d2dd25e613c470e379df4ff28f4935e
		//被测函数参数定义
		String String_p_0 = "admin";
		String String_p_1 = "123456";
		//成员变量设置

		//返回值定义 
<<<<<<< HEAD
		String result_expected = "{\"activated\":0,\"created\":1490756162,\"email\":\"1034683568@qq.com\",\"groupName\":\"visitor\",\"logged\":0,\"password\":\"a66abb5684c45962d887564f08346e8d\",\"screenName\":\"admin1\",\"uid\":1,\"username\":\"admin\"}";

		PowerMockito.mockStatic(cn.luischen.utils.TaleUtils.class);
		java.lang.String mock_result_String2 = "\"a66abb5684c45962d887564f08346e8d\"";
		cn.luischen.model.UserDomain mock_result_UserDomain1 = JSON.parseObject(
				"{\"activated\":0,\"created\":1490756162,\"email\":\"1034683568@qq.com\",\"groupName\":\"visitor\",\"logged\":0,\"password\":\"a66abb5684c45962d887564f08346e8d\",\"screenName\":\"admin1\",\"uid\":1,\"username\":\"admin\"}",
				cn.luischen.model.UserDomain.class);

		PowerMockito.when(cn.luischen.utils.TaleUtils.MD5encode(anyString())).thenReturn(mock_result_String2);
		PowerMockito.when(mock_UserDao.getUserInfoByCond(anyString(), anyString())).thenReturn(mock_result_UserDomain1);

		cn.luischen.model.UserDomain unitspirit_result = unitspirit_fixture.login(String_p_0, String_p_1);
		UnitAssert.assertEquals(result_expected, UnitSpiritFastJsonUtil.getJsonString2(unitspirit_result));
	}

=======
		//该函数无返回值 

		PowerMockito.mockStatic(cn.luischen.utils.TaleUtils.class);
		java.lang.String mock_result_String3 = "a66abb5684c45962d887564f08346e8d";
		cn.luischen.model.UserDomain mock_result_UserDomain2 = null;
		PowerMockito.mockStatic(cn.luischen.exception.BusinessException.class);
		cn.luischen.exception.BusinessException mock_result_BusinessException1 = JSON
				.parseObject(
						"{\"@type\":\"cn.luischen.exception.BusinessException\",\"errorCode\":\"用户名不存在或密码错误\",\"stackTrace\":[{\"fileName\":\"BusinessException.java\",\"methodName\":\"withErrorCode\",\"lineNumber\":53},{\"fileName\":\"UserServiceImpl.java\",\"methodName\":\"login\",\"lineNumber\":63},{\"fileName\":\"<generated>\",\"methodName\":\"invoke\",\"lineNumber\":-1},{\"fileName\":\"MethodProxy.java\",\"methodName\":\"invoke\",\"lineNumber\":204},{\"fileName\":\"CglibAopProxy.java\",\"methodName\":\"intercept\",\"lineNumber\":685},{\"fileName\":\"<generated>\",\"methodName\":\"login\",\"lineNumber\":-1},{\"fileName\":\"AuthController.java\",\"methodName\":\"toLogin\",\"lineNumber\":80},{\"fileName\":\"<generated>\",\"methodName\":\"invoke\",\"lineNumber\":-1},{\"fileName\":\"MethodProxy.java\",\"methodName\":\"invoke\",\"lineNumber\":204},{\"fileName\":\"CglibAopProxy.java\",\"methodName\":\"invokeJoinpoint\",\"lineNumber\":747},{\"fileName\":\"ReflectiveMethodInvocation.java\",\"methodName\":\"proceed\",\"lineNumber\":163},{\"fileName\":\"MethodBeforeAdviceInterceptor.java\",\"methodName\":\"invoke\",\"lineNumber\":52},{\"fileName\":\"ReflectiveMethodInvocation.java\",\"methodName\":\"proceed\",\"lineNumber\":185},{\"fileName\":\"AfterReturningAdviceInterceptor.java\",\"methodName\":\"invoke\",\"lineNumber\":52},{\"fileName\":\"ReflectiveMethodInvocation.java\",\"methodName\":\"proceed\",\"lineNumber\":185},{\"fileName\":\"ExposeInvocationInterceptor.java\",\"methodName\":\"invoke\",\"lineNumber\":92},{\"fileName\":\"ReflectiveMethodInvocation.java\",\"methodName\":\"proceed\",\"lineNumber\":185},{\"fileName\":\"CglibAopProxy.java\",\"methodName\":\"intercept\",\"lineNumber\":689},{\"fileName\":\"<generated>\",\"methodName\":\"toLogin\",\"lineNumber\":-1},{\"fileName\":\"NativeMethodAccessorImpl.java\",\"methodName\":\"invoke0\",\"lineNumber\":-2},{\"fileName\":\"NativeMethodAccessorImpl.java\",\"methodName\":\"invoke\",\"lineNumber\":62},{\"fileName\":\"DelegatingMethodAccessorImpl.java\",\"methodName\":\"invoke\",\"lineNumber\":43},{\"fileName\":\"Method.java\",\"methodName\":\"invoke\",\"lineNumber\":498},{\"fileName\":\"InvocableHandlerMethod.java\",\"methodName\":\"doInvoke\",\"lineNumber\":209},{\"fileName\":\"InvocableHandlerMethod.java\",\"methodName\":\"invokeForRequest\",\"lineNumber\":136},{\"fileName\":\"ServletInvocableHandlerMethod.java\",\"methodName\":\"invokeAndHandle\",\"lineNumber\":102},{\"fileName\":\"RequestMappingHandlerAdapter.java\",\"methodName\":\"invokeHandlerMethod\",\"lineNumber\":877},{\"fileName\":\"RequestMappingHandlerAdapter.java\",\"methodName\":\"handleInternal\",\"lineNumber\":783},{\"fileName\":\"AbstractHandlerMethodAdapter.java\",\"methodName\":\"handle\",\"lineNumber\":87},{\"fileName\":\"DispatcherServlet.java\",\"methodName\":\"doDispatch\",\"lineNumber\":991},{\"fileName\":\"DispatcherServlet.java\",\"methodName\":\"doService\",\"lineNumber\":925},{\"fileName\":\"FrameworkServlet.java\",\"methodName\":\"processRequest\",\"lineNumber\":974},{\"fileName\":\"FrameworkServlet.java\",\"methodName\":\"doPost\",\"lineNumber\":877},{\"fileName\":\"HttpServlet.java\",\"methodName\":\"service\",\"lineNumber\":661},{\"fileName\":\"FrameworkServlet.java\",\"methodName\":\"service\",\"lineNumber\":851},{\"fileName\":\"HttpServlet.java\",\"methodName\":\"service\",\"lineNumber\":742},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"internalDoFilter\",\"lineNumber\":231},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"doFilter\",\"lineNumber\":166},{\"fileName\":\"WsFilter.java\",\"methodName\":\"doFilter\",\"lineNumber\":52},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"internalDoFilter\",\"lineNumber\":193},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"doFilter\",\"lineNumber\":166},{\"fileName\":\"WebStatFilter.java\",\"methodName\":\"doFilter\",\"lineNumber\":123},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"internalDoFilter\",\"lineNumber\":193},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"doFilter\",\"lineNumber\":166},{\"fileName\":\"RequestContextFilter.java\",\"methodName\":\"doFilterInternal\",\"lineNumber\":99},{\"fileName\":\"OncePerRequestFilter.java\",\"methodName\":\"doFilter\",\"lineNumber\":107},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"internalDoFilter\",\"lineNumber\":193},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"doFilter\",\"lineNumber\":166},{\"fileName\":\"HttpPutFormContentFilter.java\",\"methodName\":\"doFilterInternal\",\"lineNumber\":109},{\"fileName\":\"OncePerRequestFilter.java\",\"methodName\":\"doFilter\",\"lineNumber\":107},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"internalDoFilter\",\"lineNumber\":193},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"doFilter\",\"lineNumber\":166},{\"fileName\":\"HiddenHttpMethodFilter.java\",\"methodName\":\"doFilterInternal\",\"lineNumber\":81},{\"fileName\":\"OncePerRequestFilter.java\",\"methodName\":\"doFilter\",\"lineNumber\":107},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"internalDoFilter\",\"lineNumber\":193},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"doFilter\",\"lineNumber\":166},{\"fileName\":\"CharacterEncodingFilter.java\",\"methodName\":\"doFilterInternal\",\"lineNumber\":200},{\"fileName\":\"OncePerRequestFilter.java\",\"methodName\":\"doFilter\",\"lineNumber\":107},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"internalDoFilter\",\"lineNumber\":193},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"doFilter\",\"lineNumber\":166},{\"fileName\":\"StandardWrapperValve.java\",\"methodName\":\"invoke\",\"lineNumber\":198},{\"fileName\":\"StandardContextValve.java\",\"methodName\":\"invoke\",\"lineNumber\":96},{\"fileName\":\"AuthenticatorBase.java\",\"methodName\":\"invoke\",\"lineNumber\":496},{\"fileName\":\"StandardHostValve.java\",\"methodName\":\"invoke\",\"lineNumber\":140},{\"fileName\":\"ErrorReportValve.java\",\"methodName\":\"invoke\",\"lineNumber\":81},{\"fileName\":\"StandardEngineValve.java\",\"methodName\":\"invoke\",\"lineNumber\":87},{\"fileName\":\"CoyoteAdapter.java\",\"methodName\":\"service\",\"lineNumber\":342},{\"fileName\":\"Http11Processor.java\",\"methodName\":\"service\",\"lineNumber\":803},{\"fileName\":\"AbstractProcessorLight.java\",\"methodName\":\"process\",\"lineNumber\":66},{\"fileName\":\"AbstractProtocol.java\",\"methodName\":\"process\",\"lineNumber\":790},{\"fileName\":\"NioEndpoint.java\",\"methodName\":\"doRun\",\"lineNumber\":1459},{\"fileName\":\"SocketProcessorBase.java\",\"methodName\":\"run\",\"lineNumber\":49},{\"fileName\":\"ThreadPoolExecutor.java\",\"methodName\":\"runWorker\",\"lineNumber\":1149},{\"fileName\":\"ThreadPoolExecutor.java\",\"methodName\":\"run\",\"lineNumber\":624},{\"fileName\":\"TaskThread.java\",\"methodName\":\"run\",\"lineNumber\":61},{\"fileName\":\"Thread.java\",\"methodName\":\"run\",\"lineNumber\":748}],\"errorMessageArguments\":[]}",
						cn.luischen.exception.BusinessException.class);

		PowerMockito.when(cn.luischen.utils.TaleUtils.MD5encode(anyString()))
				.thenReturn(mock_result_String3);
		PowerMockito.when(
				mock_UserDao.getUserInfoByCond(anyString(), anyString()))
				.thenReturn(mock_result_UserDomain2);
		PowerMockito.when(
				cn.luischen.exception.BusinessException
						.withErrorCode(anyString())).thenReturn(
				mock_result_BusinessException1);

		unitspirit_fixture.login(String_p_0, String_p_1);
		fail();
	}
>>>>>>> 3b028d6f1d2dd25e613c470e379df4ff28f4935e
}
